home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 2510.ZIP / TRSOURCE.EXE / EOQTR.C < prev    next >
C/C++ Source or Header  |  1990-10-22  |  883b  |  40 lines

  1. /*********
  2. *
  3. * EOQTR.C
  4. *
  5. * by Tom Rettig
  6. *
  7. * Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  8. *
  9. * Syntax: EOQTR( <expD> )
  10. * Return: <expD> date of last day of <date>'s calendar quarter
  11. *********/
  12.  
  13. #include "trlib.h"
  14.  
  15. TRTYPE eoqtr()
  16. {
  17.    int month;
  18.    int day;
  19.    char *ds;
  20.  
  21.    if ( PCOUNT == 1 && ISDATE(1) )
  22.    {
  23.       ds = _pards(1);
  24.       month = DSMONTH(ds);         /* Extract month from date string */
  25.       month = (((month + 2) / 3) * 3);  /* Convert month to 3, 6, 9, or 12 */
  26.       day = _tr_ldm(month, DSYEAR(ds)); /* day is last day of new month */
  27.  
  28.       ds[4] = (month / 10) + '0';  /* Break up digits and convert to ASCII */
  29.       ds[5] = (month % 10) + '0';
  30.       ds[6] = (day / 10) + '0';    /* Likewise with day */
  31.       ds[7] = (day % 10) + '0';
  32.  
  33.       _retds( ds);
  34.    }
  35.    else
  36.       _retds( BLANKDS );
  37. }
  38.  
  39.  
  40.